package jiakuang2;
import java.util.HashSet;
import java.util.Set;
public class learn2 {
    private int   id;
    private String newsName;
    private String userName;
    //无参构造方法
    public   learn2(){

    }
    //有参构造方法
    public learn2(int  id, String newsName, String userName) {
        this.id = id;
        this.newsName = newsName;
        this.userName = userName;
    }

    public  int   getId() {
        return id;
    }

    public void setId(int  id) {
        this.id = id;
    }

    public String getNewsName() {
        return newsName;
    }

    public void setNewsName(String newsName) {
        this.newsName = newsName;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
    public static void main(String[] args) {
        //创建数据
        learn2 th = new learn2(1, "火山爆发", "朱玉");
        learn2 th1 = new learn2(2, "疫情爆发", "预祝");
        learn2 th2 = new learn2(3, "粮食危机", "玉竹");
        learn2 th3 = new learn2(4, "火山爆发", "周一");
        //创建集合
        Set set = new HashSet();
        //添加数据
        set.add(th);
        set.add(th1);
        set.add(th2);
        set.add(th3);
        //增
        //遍历
        for (Object object : set) {
            learn2 ht = (learn2) object;
            System.out.println(ht.getId() + ht.getNewsName() + ht.getUserName());}
        //删
        set.remove(th3);
        for (Object Object : set) {
            learn2 ht1 = (learn2) Object;
            System.out.println(ht1.getId() + th1.getNewsName() + ht1.getUserName());

        }

    }
}


